import request from "@/utils/request";

const USER_BASE_URL = "follow";

class FollowAPI {
  /**
   * 获取用户分页列表
   *
   * @param queryParams 查询参数
   */
  static getPage(data: any) {
    return request<any, PageResult<UserFollowVO[]>>({
      url: `${USER_BASE_URL}/check`,
      method: "post",
      data,
    });
  }

  /**
   * 获得当前用户的所有关注
   */
  static getAllFollowing() {
    return request<any, PageResult<UserFollowVO[]>>({
      url: `${USER_BASE_URL}/getAllFollowing`,
      method: "get",
    });
  }

  /** 根据ID删除*/
  static deleteUserById(id: any) {
    return request({
      url: `${USER_BASE_URL}/del?id=${id}`,
      method: "post",
    });
  }

  /** 修改分组*/
  static updateGroup(data: any) {
    return request({
      url: `${USER_BASE_URL}/update`,
      method: "post",
      data,
    });
  }

  /**
   * 批量删除用户，多个以英文逗号(,)分割
   *
   * @param ids 用户ID字符串，多个以英文逗号(,)分割
   */
  static deleteByIds(id: string) {
    return request({
      url: `${USER_BASE_URL}/del`,
      method: "post",
      params: { ids: id },
    });
  }

  /**
   * 关注指定用户
   */
  static followUser(data) {
    return request({
      url: `${USER_BASE_URL}/add`,
      method: "post",
      data,
    });
  }
}

export default FollowAPI;

/**
 * 用户分页查询对象
 */
export interface UserFollowQuery extends PageQuery {
  /** 昵称 */
  nickname?: string;
  /** 用户组名称 */
  groupName?: string;
}

/** 关注分页对象 */
export interface UserFollowVO {
  //数据id
  id?: number;
  //头像
  avatar?: string;
  //用户名
  username?: string;
  //手机号
  mobile?: string;
  //简介
  discription?: string;
  //昵称
  nickname?: string;
  //关注id
  followId?: number;
  //关注分组
  groupName?: string;
}
